home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #12 / Amiga Plus CD - 2002 - No. 12.iso / Games / saga / source / counters.c < prev    next >
C/C++ Source or Header  |  2002-11-04  |  24KB  |  642 lines

  1. #include <exec/types.h>
  2. #include <exec/alerts.h>
  3. #include <intuition/intuition.h>
  4. #include <graphics/gfx.h>
  5. #include <graphics/displayinfo.h>
  6. #include <graphics/gels.h>
  7. #include <graphics/view.h>
  8.  
  9. #include <stdlib.h>
  10.  
  11. #include "animtools.h"
  12. #include "saga.h"
  13. #include "counters.h"
  14.  
  15. IMPORT struct GfxBase*       GfxBase;
  16. IMPORT struct Window        *MainWindowPtr,
  17.                             *InfoWindowPtr;
  18. IMPORT struct WorldStruct    world[36 + 30];
  19. IMPORT struct HeroStruct     hero[HEROES + 1];
  20. IMPORT struct JarlStruct     jarl[JARLS + 1];
  21. IMPORT struct MonsterStruct  monster[MONSTERS + 1];
  22. IMPORT struct TreasureStruct treasure[TREASURES + 1];
  23. IMPORT struct SordStruct     sord[SORDS + 1];
  24. IMPORT UWORD                 DisplayDepth;
  25.  
  26. MODULE struct GelsInfo      *GInfoPtr     = NULL,
  27.                             *InfoGInfoPtr = NULL;
  28. MODULE struct Bob           *InfoBobPtr[TREASURES + 1 + 1],
  29.                             *HeroBobPtr[HEROES + 1],
  30.                             *JarlBobPtr[JARLS + 1],
  31.                             *MonsterBobPtr[MONSTERS + 1],
  32.                             *TreasureBobPtr[TREASURES + 1],
  33.                             *SordBobPtr[SORDS + 1];
  34.  
  35. /* The word `Sword' is deliberately mispelled (within the source code) as
  36.    Sord. This avoids collisions with the SWORD (signed word) typedef. */
  37.  
  38. NEWBOB NewBob =
  39. {   NULL,               // initial image
  40.     COUNTERWIDTH,       // width in words
  41.     COUNTERHEIGHT,      // line height
  42.     DEPTH,              // image depth
  43.     0x7F,               // PlanePick
  44.     0,                  // PlaneOnOff
  45.     SAVEBACK | OVERLAY, // VSprite flags
  46.     FALSE,              // double buffer?
  47.     0,                  // raster depth
  48.     HIDDEN_X, HIDDEN_Y, // x, y position (filled later)
  49.     0,                  // hit mask
  50.     0                   // me mask
  51. };
  52.  
  53. AGLOBAL void createcounters(void)
  54. {   SLONG whichhero, whichjarl, whichmonster, whichtreasure, whichsord;
  55.  
  56.     if (!(GInfoPtr = setupGelSys(MainWindowPtr->RPort, 0x03)))
  57.     {   DisplayAlert(AT_Recovery, "\0\20\20Saga: Can't set up GELs!\0", 24);
  58.         cleanexit(EXIT_FAILURE);
  59.     }
  60.     NewBob.nb_RasDepth = DisplayDepth;
  61.  
  62.     for (whichhero = 0; whichhero <= HEROES; whichhero++)
  63.     {   NewBob.nb_Image = HeroData[whichhero];
  64.         if (!(HeroBobPtr[whichhero] = makeBob(&NewBob)))
  65.         {   DisplayAlert(AT_Recovery, "\0\20\20Saga: Can't make hero bob(s)!\0", 24);
  66.             cleanexit(EXIT_FAILURE);
  67.         }
  68.         AddBob(HeroBobPtr[whichhero], MainWindowPtr->RPort);
  69.     }
  70.     for (whichjarl = 0; whichjarl <= JARLS; whichjarl++)
  71.     {   NewBob.nb_Image = UnknownJarlData;
  72.         if (!(JarlBobPtr[whichjarl] = makeBob(&NewBob)))
  73.         {   DisplayAlert(AT_Recovery, "\0\20\20Saga: Can't make jarl bob(s)!\0", 24);
  74.             cleanexit(EXIT_FAILURE);
  75.         }
  76.         AddBob(JarlBobPtr[whichjarl], MainWindowPtr->RPort);
  77.     }
  78.     for (whichmonster = 0; whichmonster <= MONSTERS; whichmonster++)
  79.     {   NewBob.nb_Image = MonsterData[whichmonster];
  80.         if (!(MonsterBobPtr[whichmonster] = makeBob(&NewBob)))
  81.         {   DisplayAlert(AT_Recovery, "\0\20\20Saga: Can't make monster bob(s)!\0", 24);
  82.             cleanexit(EXIT_FAILURE);
  83.         }
  84.         AddBob(MonsterBobPtr[whichmonster], MainWindowPtr->RPort);
  85.     }
  86.     for (whichtreasure = 0; whichtreasure <= TREASURES; whichtreasure++)
  87.     {   NewBob.nb_Image = TreasureData[whichtreasure];
  88.         if (!(TreasureBobPtr[whichtreasure] = makeBob(&NewBob)))
  89.         {   DisplayAlert(AT_Recovery, "\0\20\20Saga: Can't make treasure bob(s)!\0", 24);
  90.             cleanexit(EXIT_FAILURE);
  91.         }
  92.         AddBob(TreasureBobPtr[whichtreasure], MainWindowPtr->RPort);
  93.     }
  94.     for (whichsord = 0; whichsord <= SORDS; whichsord++)
  95.     {   NewBob.nb_Image = SordData[whichsord];
  96.         if (!(SordBobPtr[whichsord] = makeBob(&NewBob)))
  97.         {   DisplayAlert(AT_Recovery, "\0\20\20Saga: Can't make sord bob(s)!\0", 24);
  98.             cleanexit(EXIT_FAILURE);
  99.         }
  100.         AddBob(SordBobPtr[whichsord], MainWindowPtr->RPort);
  101. }   }
  102.  
  103. AGLOBAL void destroycounters(void)
  104. {   SLONG whichhero, whichjarl, whichmonster, whichtreasure, whichsord;
  105.  
  106.     for (whichhero = 0; whichhero <= HEROES; whichhero++)
  107.     {   if (HeroBobPtr[whichhero])
  108.         {   remove_hero(whichhero, FALSE);
  109.             RemBob(HeroBobPtr[whichhero]);
  110.     }   }
  111.     for (whichjarl = 0; whichjarl <= JARLS; whichjarl++)
  112.     {   if (JarlBobPtr[whichjarl])
  113.         {   remove_jarl(whichjarl, FALSE);
  114.             RemBob(JarlBobPtr[whichjarl]);
  115.     }   }
  116.     for (whichmonster = 0; whichmonster <= MONSTERS; whichmonster++)
  117.     {   if (MonsterBobPtr[whichmonster])
  118.         {   remove_monster(whichmonster, FALSE);
  119.             RemBob(MonsterBobPtr[whichmonster]);
  120.     }   }
  121.     for (whichtreasure = 0; whichtreasure <= TREASURES; whichtreasure++)
  122.     {   if (TreasureBobPtr[whichtreasure])
  123.         {   remove_treasure(whichtreasure, FALSE);
  124.             RemBob(TreasureBobPtr[whichtreasure]);
  125.     }   }
  126.     for (whichsord = 0; whichsord <= SORDS; whichsord++)
  127.     {   if (SordBobPtr[whichsord])
  128.         {   remove_sord(whichsord, FALSE);
  129.             RemBob(SordBobPtr[whichsord]);
  130.     }   }
  131.  
  132.     if (GInfoPtr)
  133.     {   refreshcounters();
  134.     }
  135.     for (whichhero = 0; whichhero <= HEROES; whichhero++)
  136.     {   if (HeroBobPtr[whichhero])
  137.         {   freeBob(HeroBobPtr[whichhero], NewBob.nb_RasDepth);
  138.             HeroBobPtr[whichhero] = NULL;
  139.     }   }
  140.     for (whichjarl = 0; whichjarl <= JARLS; whichjarl++)
  141.     {   if (JarlBobPtr[whichjarl])
  142.         {   freeBob(JarlBobPtr[whichjarl], NewBob.nb_RasDepth);
  143.             JarlBobPtr[whichjarl] = NULL;
  144.     }   }
  145.     for (whichmonster = 0; whichmonster <= MONSTERS; whichmonster++)
  146.     {   if (MonsterBobPtr[whichmonster])
  147.         {   freeBob(MonsterBobPtr[whichmonster], NewBob.nb_RasDepth);
  148.             MonsterBobPtr[whichmonster] = NULL;
  149.     }   }
  150.     for (whichtreasure = 0; whichtreasure <= TREASURES; whichtreasure++)
  151.     {   if (TreasureBobPtr[whichtreasure])
  152.         {   freeBob(TreasureBobPtr[whichtreasure], NewBob.nb_RasDepth);
  153.             TreasureBobPtr[whichtreasure] = NULL;
  154.     }   }
  155.     for (whichsord = 0; whichsord <= SORDS; whichsord++)
  156.     {   if (SordBobPtr[whichsord])
  157.         {   freeBob(SordBobPtr[whichsord], NewBob.nb_RasDepth);
  158.             SordBobPtr[whichsord] = NULL;
  159.     }   }
  160.  
  161.     if (GInfoPtr)
  162.     {   cleanupGelSys(GInfoPtr, MainWindowPtr->RPort);
  163. }   }
  164.  
  165. AGLOBAL void unslot_hero(SLONG whichhero)
  166. {   if (hero[whichhero].slot != -1)
  167.     {   world[hero[whichhero].where].slot[hero[whichhero].slot] = FALSE;
  168.         hero[whichhero].slot = -1;
  169. }   }
  170. AGLOBAL void unslot_jarl(SLONG whichjarl)
  171. {   if (jarl[whichjarl].slot != -1)
  172.     {   world[jarl[whichjarl].where].slot[jarl[whichjarl].slot] = FALSE;
  173.         jarl[whichjarl].slot = -1;
  174. }   }
  175. AGLOBAL void unslot_monster(SLONG whichmonster)
  176. {   if (monster[whichmonster].slot != -1)
  177.     {   world[monster[whichmonster].where].slot[monster[whichmonster].slot] = FALSE;
  178.         monster[whichmonster].slot = -1;
  179. }   }
  180. AGLOBAL void unslot_treasure(SLONG whichtreasure)
  181. {   if (treasure[whichtreasure].slot != -1)
  182.     {   world[treasure[whichtreasure].where].slot[treasure[whichtreasure].slot] = FALSE;
  183.         treasure[whichtreasure].slot = -1;
  184. }   }
  185. AGLOBAL void unslot_sord(SLONG whichsord)
  186. {   if (sord[whichsord].slot != -1)
  187.     {   world[sord[whichsord].where].slot[sord[whichsord].slot] = FALSE;
  188.         sord[whichsord].slot = -1;
  189. }   }
  190.  
  191. AGLOBAL void move_hero(SLONG whichhero, FLAG display)
  192. {   SLONG whichslot;
  193.  
  194.     // This assumes the counter has already been unslotted from its old
  195.     // location.
  196.     for (whichslot = 0; whichslot <= SLOTS; whichslot++)
  197.     {   if (!(world[hero[whichhero].where].slot[whichslot]))
  198.         {   hero[whichhero].slot = whichslot;
  199.             break;
  200.     }   }
  201.     world[hero[whichhero].where].slot[whichslot] = TRUE;
  202.  
  203.     HeroBobPtr[whichhero]->BobVSprite->X = world[hero[whichhero].where].centrex - 12;
  204.     HeroBobPtr[whichhero]->BobVSprite->Y = world[hero[whichhero].where].centrey - 12 - (whichslot * 7);
  205.     if (display)
  206.     {   refreshcounters();
  207. }   }
  208. AGLOBAL void move_monster(SLONG whichmonster, FLAG display)
  209. {   SLONG whichslot;
  210.  
  211.     // This assumes the counter has already been unslotted from its old
  212.     // location.
  213.     for (whichslot = 0; whichslot <= SLOTS; whichslot++)
  214.     {   if (!(world[monster[whichmonster].where].slot[whichslot]))
  215.         {   monster[whichmonster].slot = whichslot;
  216.             break;
  217.     }   }
  218.     world[monster[whichmonster].where].slot[whichslot] = TRUE;
  219.  
  220.     MonsterBobPtr[whichmonster]->BobVSprite->X = world[monster[whichmonster].where].centrex - 12;
  221.     MonsterBobPtr[whichmonster]->BobVSprite->Y = world[monster[whichmonster].where].centrey - 12 - (whichslot * 7);
  222.     if (display)
  223.     {   refreshcounters();
  224. }   }
  225. AGLOBAL void move_jarl(SLONG whichjarl, FLAG display)
  226. {   SLONG whichslot;
  227.  
  228.     // This assumes the counter has already been unslotted from its old
  229.     // location.
  230.     for (whichslot = 0; whichslot <= SLOTS; whichslot++)
  231.     {   if (!(world[jarl[whichjarl].where].slot[whichslot]))
  232.         {   jarl[whichjarl].slot = whichslot;
  233.             break;
  234.     }   }
  235.     world[jarl[whichjarl].where].slot[whichslot] = TRUE;
  236.  
  237.     JarlBobPtr[whichjarl]->BobVSprite->X = world[jarl[whichjarl].where].centrex - 12;
  238.     JarlBobPtr[whichjarl]->BobVSprite->Y = world[jarl[whichjarl].where].centrey - 12 - (whichslot * 7);
  239.     if (display)
  240.     {   refreshcounters();
  241. }   }
  242. AGLOBAL void move_treasure(SLONG whichtreasure, FLAG display)
  243. {   SLONG whichslot;
  244.  
  245.     // This assumes the counter has already been unslotted from its old
  246.     // location.
  247.     for (whichslot = 0; whichslot <= SLOTS; whichslot++)
  248.     {   if (!(world[treasure[whichtreasure].where].slot[whichslot]))
  249.         {   treasure[whichtreasure].slot = whichslot;
  250.             break;
  251.     }   }
  252.     world[treasure[whichtreasure].where].slot[whichslot] = TRUE;
  253.  
  254.     TreasureBobPtr[whichtreasure]->BobVSprite->X = world[treasure[whichtreasure].where].centrex - 12;
  255.     TreasureBobPtr[whichtreasure]->BobVSprite->Y = world[treasure[whichtreasure].where].centrey - 12 - (whichslot * 7);
  256.     if (display)
  257.     {   refreshcounters();
  258. }   }
  259. AGLOBAL void move_sord(SLONG whichsord, FLAG display)
  260. {   SLONG whichslot;
  261.  
  262.     // This assumes the counter has already been unslotted from its old
  263.     // location.
  264.     for (whichslot = 0; whichslot <= SLOTS; whichslot++)
  265.     {   if (!(world[sord[whichsord].where].slot[whichslot]))
  266.         {   sord[whichsord].slot = whichslot;
  267.             break;
  268.     }   }
  269.     world[sord[whichsord].where].slot[whichslot] = TRUE;
  270.  
  271.     SordBobPtr[whichsord]->BobVSprite->X = world[sord[whichsord].where].centrex - 12;
  272.     SordBobPtr[whichsord]->BobVSprite->Y = world[sord[whichsord].where].centrey - 12 - (whichslot * 7);
  273.     if (display)
  274.     {   refreshcounters();
  275. }   }
  276.  
  277. AGLOBAL void init_counters(void)
  278. {   SLONG whichhero, whichinfobob, whichjarl, whichmonster, whichtreasure,
  279.           whichsord;
  280.  
  281.     for (whichhero = 0; whichhero <= HEROES; whichhero++)
  282.     {   hero[whichhero].slot = -1;
  283.         HeroBobPtr[whichhero] = NULL;
  284.     }
  285.     for (whichjarl = 0; whichjarl <= JARLS; whichjarl++)
  286.     {   jarl[whichjarl].slot = -1;
  287.         JarlBobPtr[whichjarl] = NULL;
  288.     }
  289.     for (whichmonster = 0; whichmonster <= MONSTERS; whichmonster++)
  290.     {   monster[whichmonster].slot = -1;
  291.         MonsterBobPtr[whichmonster] = NULL;
  292.     }
  293.     for (whichtreasure = 0; whichtreasure <= TREASURES; whichtreasure++)
  294.     {   treasure[whichtreasure].slot = -1;
  295.         TreasureBobPtr[whichtreasure] = NULL;
  296.     }
  297.     for (whichsord = 0; whichsord <= SORDS; whichsord++)
  298.     {   sord[whichsord].slot = -1;
  299.         SordBobPtr[whichsord] = NULL;
  300.     }
  301.     for (whichinfobob = 0; whichinfobob <= TREASURES + 1; whichinfobob++)
  302.     {   InfoBobPtr[whichinfobob] = NULL;
  303. }   }
  304.  
  305. AGLOBAL void revealjarl(SLONG whichjarl, FLAG display)
  306. {   jarl[whichjarl].face        = FACEUP;
  307.     jarl[whichjarl].recruitable = TRUE;
  308.     JarlBobPtr[whichjarl]->BobVSprite->ImageData = JarlData[whichjarl];
  309.     // InitMasks(JarlBobPtr[whichjarl]->BobVSprite);
  310.     if (display)
  311.     {   refreshcounters();
  312. }   }
  313.  
  314. AGLOBAL void hidejarl(SLONG whichjarl, FLAG display)
  315. {   jarl[whichjarl].face        = FACEDOWN;
  316.     jarl[whichjarl].recruitable = FALSE;
  317.     JarlBobPtr[whichjarl]->BobVSprite->ImageData = UnknownJarlData;
  318.     // InitMasks(JarlBobPtr[whichjarl]->BobVSprite);
  319.     if (display)
  320.     {   refreshcounters();
  321. }   }
  322.  
  323. AGLOBAL SLONG checkcounters(SWORD mousex, SWORD mousey, SLONG* countertype)
  324. {   SLONG foundy,
  325.           whichhero,
  326.           whichcounter = -1,
  327.           whichjarl,
  328.           whichmonster,
  329.           whichtreasure, whichsord;
  330.     FLAG  found = FALSE;
  331.  
  332.     *(countertype) = -1;
  333.  
  334.     /* This assumes that counters with higher y-values (ie. lower on the
  335.     screen) have higher priority than those with lower y-values. */
  336.  
  337.     // find all counters lying under the pointer
  338.     for (whichhero = 0; whichhero <= HEROES; whichhero++)
  339.     {   if
  340.         (   mousex >= HeroBobPtr[whichhero]->BobVSprite->X
  341.          && mousex <= HeroBobPtr[whichhero]->BobVSprite->X + 24 - 1
  342.          && mousey >= HeroBobPtr[whichhero]->BobVSprite->Y
  343.          && mousey <= HeroBobPtr[whichhero]->BobVSprite->Y + 24 - 1
  344.         )
  345.         {   hero[whichhero].foundbob = TRUE;
  346.             found = TRUE;
  347.     }   }
  348.     for (whichjarl = 0; whichjarl <= JARLS; whichjarl++)
  349.     {   if
  350.         (   mousex >= JarlBobPtr[whichjarl]->BobVSprite->X
  351.          && mousex <= JarlBobPtr[whichjarl]->BobVSprite->X + 24 - 1
  352.          && mousey >= JarlBobPtr[whichjarl]->BobVSprite->Y
  353.          && mousey <= JarlBobPtr[whichjarl]->BobVSprite->Y + 24 - 1
  354.         )
  355.         {   jarl[whichjarl].foundbob = TRUE;
  356.             found = TRUE;
  357.     }   }
  358.     for (whichmonster = 0; whichmonster <= MONSTERS; whichmonster++)
  359.     {   if
  360.         (   mousex >= MonsterBobPtr[whichmonster]->BobVSprite->X
  361.          && mousex <= MonsterBobPtr[whichmonster]->BobVSprite->X + 24 - 1
  362.          && mousey >= MonsterBobPtr[whichmonster]->BobVSprite->Y
  363.          && mousey <= MonsterBobPtr[whichmonster]->BobVSprite->Y + 24 - 1
  364.         )
  365.         {   monster[whichmonster].foundbob = TRUE;
  366.             found = TRUE;
  367.     }   }
  368.     for (whichtreasure = 0; whichtreasure <= TREASURES; whichtreasure++)
  369.     {   if
  370.         (   mousex >= TreasureBobPtr[whichtreasure]->BobVSprite->X
  371.          && mousex <= TreasureBobPtr[whichtreasure]->BobVSprite->X + 24 - 1
  372.          && mousey >= TreasureBobPtr[whichtreasure]->BobVSprite->Y
  373.          && mousey <= TreasureBobPtr[whichtreasure]->BobVSprite->Y + 24 - 1
  374.         )
  375.         {   treasure[whichtreasure].foundbob = TRUE;
  376.             found = TRUE;
  377.     }   }
  378.     for (whichsord = 0; whichsord <= SORDS; whichsord++)
  379.     {   if
  380.         (   mousex >= SordBobPtr[whichsord]->BobVSprite->X
  381.          && mousex <= SordBobPtr[whichsord]->BobVSprite->X + 24 - 1
  382.          && mousey >= SordBobPtr[whichsord]->BobVSprite->Y
  383.          && mousey <= SordBobPtr[whichsord]->BobVSprite->Y + 24 - 1
  384.         )
  385.         {   sord[whichsord].foundbob = TRUE;
  386.             found = TRUE;
  387.     }   }
  388.  
  389.     if (!found)
  390.     {   return(-1);
  391.     }
  392.  
  393.     // determine which counter is topmost (ie. which is lower on the screen)
  394.     foundy = -1;
  395.     for (whichhero = 0; whichhero <= HEROES; whichhero++)
  396.     {   if
  397.         (   hero[whichhero].foundbob
  398.          && HeroBobPtr[whichhero]->BobVSprite->Y > foundy
  399.         )
  400.         {   whichcounter = whichhero;
  401.             *(countertype) = HERO;
  402.             foundy = HeroBobPtr[whichhero]->BobVSprite->Y;
  403.         }
  404.         hero[whichhero].foundbob = FALSE;
  405.     }
  406.     for (whichjarl = 0; whichjarl <= JARLS; whichjarl++)
  407.     {   if
  408.         (   jarl[whichjarl].foundbob
  409.          && JarlBobPtr[whichjarl]->BobVSprite->Y > foundy
  410.         )
  411.         {   whichcounter = whichjarl;
  412.             *(countertype) = JARL;
  413.             foundy = JarlBobPtr[whichjarl]->BobVSprite->Y;
  414.         }
  415.         jarl[whichjarl].foundbob = FALSE;
  416.     }
  417.     for (whichmonster = 0; whichmonster <= MONSTERS; whichmonster++)
  418.     {   if
  419.         (   monster[whichmonster].foundbob
  420.          && MonsterBobPtr[whichmonster]->BobVSprite->Y > foundy
  421.         )
  422.         {   whichcounter = whichmonster;
  423.             *(countertype) = MONSTER;
  424.             foundy = MonsterBobPtr[whichmonster]->BobVSprite->Y;
  425.         }
  426.         monster[whichmonster].foundbob = FALSE;
  427.     }
  428.     for (whichtreasure = 0; whichtreasure <= TREASURES; whichtreasure++)
  429.     {   if
  430.         (   treasure[whichtreasure].foundbob
  431.          && TreasureBobPtr[whichtreasure]->BobVSprite->Y > foundy
  432.         )
  433.         {   whichcounter = whichtreasure;
  434.             *(countertype) = TREASURE;
  435.             foundy = TreasureBobPtr[whichtreasure]->BobVSprite->Y;
  436.         }
  437.         treasure[whichtreasure].foundbob = FALSE;
  438.     }
  439.     for (whichsord = 0; whichsord <= SORDS; whichsord++)
  440.     {   if
  441.         (   sord[whichsord].foundbob
  442.          && SordBobPtr[whichsord]->BobVSprite->Y > foundy
  443.         )
  444.         {   whichcounter = whichsord;
  445.             *(countertype) = SORD;
  446.             foundy = SordBobPtr[whichsord]->BobVSprite->Y;
  447.         }
  448.         sord[whichsord].foundbob = FALSE;
  449.     }
  450.  
  451.     return(whichcounter);
  452. }
  453.  
  454. AGLOBAL void select_hero(SLONG whichhero, FLAG display)
  455. {   if (hero[whichhero].promoted != -1)
  456.     {   HeroBobPtr[whichhero]->BobVSprite->ImageData = SelectedJarlData[hero[whichhero].promoted];
  457.     } else
  458.     {   HeroBobPtr[whichhero]->BobVSprite->ImageData = SelectedHeroData[whichhero];
  459.     }
  460.     // InitMasks(HeroBobPtr[whichhero]->BobVSprite);
  461.     if (display)
  462.     {   refreshcounters();
  463. }   }
  464. AGLOBAL void deselect_hero(SLONG whichhero, FLAG display)
  465. {   if (hero[whichhero].promoted != -1)
  466.     {   HeroBobPtr[whichhero]->BobVSprite->ImageData = JarlData[hero[whichhero].promoted];
  467.     } else
  468.     {   HeroBobPtr[whichhero]->BobVSprite->ImageData = HeroData[whichhero];
  469.     }
  470.     // InitMasks(HeroBobPtr[whichhero]->BobVSprite);
  471.     if (display)
  472.     {   refreshcounters();
  473. }   }
  474. AGLOBAL void select_jarl(SLONG whichjarl, FLAG display)
  475. {   JarlBobPtr[whichjarl]->BobVSprite->ImageData = SelectedJarlData[whichjarl];
  476.     // InitMasks(JarlBobPtr[whichjarl]->BobVSprite);
  477.     if (display)
  478.     {   refreshcounters();
  479. }   }
  480. AGLOBAL void deselect_jarl(SLONG whichjarl, FLAG display)
  481. {   JarlBobPtr[whichjarl]->BobVSprite->ImageData = JarlData[whichjarl];
  482.     // InitMasks(JarlBobPtr[whichjarl]->BobVSprite);
  483.     if (display)
  484.     {   refreshcounters();
  485. }   }
  486.  
  487. AGLOBAL void remove_hero(SLONG whichhero, FLAG display)
  488. {   unslot_hero(whichhero);
  489.     HeroBobPtr[whichhero]->BobVSprite->X = HIDDEN_X;
  490.     HeroBobPtr[whichhero]->BobVSprite->Y = HIDDEN_Y;
  491.     if (display)
  492.     {   refreshcounters();
  493. }   }
  494. AGLOBAL void remove_jarl(SLONG whichjarl, FLAG display)
  495. {   unslot_jarl(whichjarl);
  496.     JarlBobPtr[whichjarl]->BobVSprite->X = HIDDEN_X;
  497.     JarlBobPtr[whichjarl]->BobVSprite->Y = HIDDEN_Y;
  498.     if (display)
  499.     {   refreshcounters();
  500. }   }
  501. AGLOBAL void remove_monster(SLONG whichmonster, FLAG display)
  502. {   unslot_monster(whichmonster);
  503.     MonsterBobPtr[whichmonster]->BobVSprite->X = HIDDEN_X;
  504.     MonsterBobPtr[whichmonster]->BobVSprite->Y = HIDDEN_Y;
  505.     if (display)
  506.     {   refreshcounters();
  507. }   }
  508. AGLOBAL void remove_treasure(SLONG whichtreasure, FLAG display)
  509. {   unslot_treasure(whichtreasure);
  510.     TreasureBobPtr[whichtreasure]->BobVSprite->X = HIDDEN_X;
  511.     TreasureBobPtr[whichtreasure]->BobVSprite->Y = HIDDEN_Y;
  512.     if (display)
  513.     {   refreshcounters();
  514. }   }
  515. AGLOBAL void remove_sord(SLONG whichsord, FLAG display)
  516. {   unslot_sord(whichsord);
  517.     SordBobPtr[whichsord]->BobVSprite->X = HIDDEN_X;
  518.     SordBobPtr[whichsord]->BobVSprite->Y = HIDDEN_Y;
  519.     if (display)
  520.     {   refreshcounters();
  521. }   }
  522.  
  523. AGLOBAL void refreshcounters(void)
  524. {   WaitTOF();
  525.     SortGList(MainWindowPtr->RPort);
  526.     DrawGList(MainWindowPtr->RPort, ViewPortAddress(MainWindowPtr));
  527.     WaitTOF();
  528. }
  529.  
  530. AGLOBAL void reset_images(void)
  531. {   SLONG whichhero;
  532.  
  533.     for (whichhero = 0; whichhero <= HEROES; whichhero++)
  534.     {   HeroBobPtr[whichhero]->BobVSprite->ImageData = HeroData[whichhero];
  535.         // InitMasks(HeroBobPtr[whichhero]->BobVSprite);
  536. }   }
  537.  
  538. AGLOBAL void hero_info(SLONG whichhero)
  539. {   SLONG infobobs = 0, whichsord, whichtreasure;
  540.  
  541.     if (!(InfoGInfoPtr = setupGelSys(InfoWindowPtr->RPort, 0x03)))
  542.     {   DisplayAlert(AT_Recovery, "\0\20\20Saga: Can't set up GELs!\0", 24);
  543.         cleanexit(EXIT_FAILURE);
  544.     }
  545.  
  546.     for (whichsord = 0; whichsord <= SORDS; whichsord++)
  547.     {   if (sord[whichsord].possessortype == HERO
  548.          && sord[whichsord].possessor     == whichhero)
  549.         {   NewBob.nb_Image = SordData[whichsord];
  550.             if (!(InfoBobPtr[0] = makeBob(&NewBob)))
  551.             {   DisplayAlert(AT_Recovery, "\0\20\20Saga: Can't make hero sword bob!\0", 24);
  552.                 cleanexit(EXIT_FAILURE);
  553.             }
  554.             AddBob(InfoBobPtr[0], InfoWindowPtr->RPort);
  555.             InfoBobPtr[0]->BobVSprite->X = 600;
  556.             InfoBobPtr[0]->BobVSprite->Y = 16;
  557.             infobobs = 1;
  558.             break;
  559.     }   }
  560.  
  561.     for (whichtreasure = 0; whichtreasure <= TREASURES; whichtreasure++)
  562.     {   if (treasure[whichtreasure].possessortype == HERO
  563.          && treasure[whichtreasure].possessor     == whichhero)
  564.         {   NewBob.nb_Image = TreasureData[whichtreasure];
  565.             if (!(InfoBobPtr[infobobs] = makeBob(&NewBob)))
  566.             {   DisplayAlert(AT_Recovery, "\0\20\20Saga: Can't make hero treasure bob(s)!\0", 24);
  567.                 cleanexit(EXIT_FAILURE);
  568.             }
  569.             AddBob(InfoBobPtr[infobobs], InfoWindowPtr->RPort);
  570.             InfoBobPtr[infobobs]->BobVSprite->X = 600;
  571.             InfoBobPtr[infobobs]->BobVSprite->Y = 16 + (infobobs * (24 + 4));
  572.             infobobs++;
  573.     }   }
  574.  
  575.     SortGList(InfoWindowPtr->RPort);
  576.     DrawGList(InfoWindowPtr->RPort, ViewPortAddress(InfoWindowPtr));
  577.     WaitTOF();
  578. }
  579.  
  580. AGLOBAL void jarl_info(SLONG whichjarl)
  581. {   SLONG infobobs = 0, whichsord, whichtreasure;
  582.  
  583.     if (!(InfoGInfoPtr = setupGelSys(InfoWindowPtr->RPort, 0x03)))
  584.     {   DisplayAlert(AT_Recovery, "\0\20\20Saga: Can't set up GELs!\0", 24);
  585.         cleanexit(EXIT_FAILURE);
  586.     }
  587.  
  588.     for (whichsord = 0; whichsord <= SORDS; whichsord++)
  589.     {   if (sord[whichsord].possessortype == JARL
  590.          && sord[whichsord].possessor     == whichjarl)
  591.         {   NewBob.nb_Image = SordData[whichsord];
  592.             if (!(InfoBobPtr[0] = makeBob(&NewBob)))
  593.             {   DisplayAlert(AT_Recovery, "\0\20\20Saga: Can't make jarl sword bob!\0", 24);
  594.                 cleanexit(EXIT_FAILURE);
  595.             }
  596.             AddBob(InfoBobPtr[0], InfoWindowPtr->RPort);
  597.             InfoBobPtr[0]->BobVSprite->X = 600;
  598.             InfoBobPtr[0]->BobVSprite->Y = 16;
  599.             infobobs = 1;
  600.             break;
  601.     }   }
  602.  
  603.     for (whichtreasure = 0; whichtreasure <= TREASURES; whichtreasure++)
  604.     {   if (treasure[whichtreasure].possessortype == JARL
  605.          && treasure[whichtreasure].possessor     == whichjarl)
  606.         {   NewBob.nb_Image = TreasureData[whichtreasure];
  607.             if (!(InfoBobPtr[infobobs] = makeBob(&NewBob)))
  608.             {   DisplayAlert(AT_Recovery, "\0\20\20Saga: Can't make jarl treasure bob(s)!\0", 24);
  609.                 cleanexit(EXIT_FAILURE);
  610.             }
  611.             AddBob(InfoBobPtr[infobobs], InfoWindowPtr->RPort);
  612.             InfoBobPtr[infobobs]->BobVSprite->X = 600;
  613.             InfoBobPtr[infobobs]->BobVSprite->Y = 16 + (infobobs * (24 + 4));
  614.             infobobs++;
  615.     }   }
  616.  
  617.     SortGList(InfoWindowPtr->RPort);
  618.     DrawGList(InfoWindowPtr->RPort, ViewPortAddress(InfoWindowPtr));
  619.     WaitTOF();
  620. }
  621.  
  622. AGLOBAL void uninfo(void)
  623. {   SLONG whichinfobob;
  624.  
  625.     for (whichinfobob = 0; whichinfobob <= TREASURES + 1; whichinfobob++)
  626.     {   if (InfoBobPtr[whichinfobob])
  627.         {   RemBob(InfoBobPtr[whichinfobob]);
  628.     }   }
  629.     if (InfoGInfoPtr)
  630.     {    SortGList(InfoWindowPtr->RPort);
  631.          DrawGList(InfoWindowPtr->RPort, ViewPortAddress(InfoWindowPtr));
  632.          WaitTOF();
  633.     }
  634.     for (whichinfobob = 0; whichinfobob <= TREASURES + 1; whichinfobob++)
  635.     {   if (InfoBobPtr[whichinfobob])
  636.         {   freeBob(InfoBobPtr[whichinfobob], NewBob.nb_RasDepth);
  637.             InfoBobPtr[whichinfobob] = NULL;
  638.     }   }
  639.     if (InfoGInfoPtr)
  640.     {   cleanupGelSys(InfoGInfoPtr, InfoWindowPtr->RPort);
  641. }   }
  642.